import React from 'react';
import { getmyprocessjsonbydeploymentid } from '@/services/flowMine/apply';

const useProcess = (processDeploymentId = '') => {
    const [data, setData] = React.useState([]);
    const [loading, setLoading] = React.useState(true);

    React.useEffect(() => {
        const fetchProcess = async () => {
            setLoading(true);
            const result = await getmyprocessjsonbydeploymentid(
                JSON.stringify({ institutionType: 'personnel' }),
                processDeploymentId
            );
            if (result.code === 10000) {
                setData(result.data);
            }
            setLoading(false);
        };
        if (processDeploymentId) {
            fetchProcess();
        }
    }, [processDeploymentId]);

    return [loading, data];
};

export default useProcess;
